import axios from 'axios'
const UPDATE_DATA = 'UPDATE_DATA'

const initState = {
  user: '', //用户名
}
//reducer
export function user(state=initState,action) {
  switch(action.type) {
    case UPDATE_DATA:
      return {...state,...action.payload}
    default :
      return state
  }
}

export function updateData(data){
  return {type:UPDATE_DATA,payload:data}
}

/* export function login({user,pwd}){
  if(!user || !pwd) {
    return errorMsg('用户密码必须输入')
  }
  return async dispatch => {
    const res = await axios.post('/user/login',{user,pwd})
    if(res.status === 200 && res.data.code === 0) {
      dispatch(authSuccess(res.data.data))
    } else {
      dispatch(errorMsg(res.data.msg))
    }
  }
} */